<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Using AppendChild</title>

    <script type="text/javascript">
        function AddSpan () {
            var span = document.createElement ("span");
            span.innerHTML = "A new span";
            span.style.color = "#ff0000";

            var container = document.getElementById ("container");
            container.appendChild (span);
        }
    </script>

</head>
<body>
    <button onclick="AddSpan ()">Create a span</button>
    <br /><br />
    <div id="container"></div>
</body>
</html>